/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.

package com.kingdee.eas.hr.rec.util;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.kdf.table.*;
import com.kingdee.bos.dao.IObjectCollection;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.framework.DynamicObjectFactory;
import com.kingdee.bos.framework.IDynamicObject;
import com.kingdee.bos.util.BOSObjectType;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.basedata.hraux.DiplomaInfo;
import com.kingdee.eas.basedata.org.AdminOrgUnitInfo;
import com.kingdee.eas.basedata.org.PositionInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.framework.client.CoreUI;
import com.kingdee.eas.hr.affair.client.HRAffairClientUtils;
import com.kingdee.eas.hr.base.SpecialityInfo;
import com.kingdee.eas.hr.rec.*;
import com.kingdee.eas.util.SysUtil;
import com.kingdee.eas.util.client.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class HRRecClientUtils extends HRAffairClientUtils {

	public HRRecClientUtils() {
	}

	public static void checkIsAudited(HRRecBaseInfo editData)
			throws BOSException, HRRecException {
		StringBuffer oql = new StringBuffer(
				"select bizState where (bizState = 3 or bizState = 4 or bizState =1) ");
		if (editData != null && editData.getId() != null) {
			oql.append(" and id = '");
			oql.append(editData.getId().toString());
			oql.append("'");
			IDynamicObject idy = DynamicObjectFactory.getRemoteInstance();
			if (idy.exists(editData.getBOSType(), oql.toString()))
				throw new HRRecException(HRRecException.BILL_NOT_EDIT);
		}
	}

	public static IObjectCollection getEntriesByKDTable(KDTable kdtable,
			IObjectCollection c) {
		if (c instanceof RequireApplyBillEntryCollection)
			return getRequireApplyBillEntriesByKDTable(kdtable);
		if (c instanceof RequireAdjustBillEntryCollection)
			return getRequireAdjustBillEntriesByKDTable(kdtable);
		else
			return null;
	}

	public static RequireApplyBillEntryCollection getRequireApplyBillEntriesByKDTable(
			KDTable kdtable) {
		RequireApplyBillEntryCollection c = new RequireApplyBillEntryCollection();
		RequireApplyBillEntryInfo info = null;
		IRow row = null;
		int i = 0;
		for (int size = kdtable.getRowCount(); i < size; i++) {
			row = kdtable.getRow(i);
			info = new RequireApplyBillEntryInfo();
			if (row.getCell("id").getValue() != null)
				info.setId(BOSUuid
						.read(row.getCell("id").getValue().toString()));
			if (row.getCell("position").getValue() != null)
				info.setPosition((PositionInfo) row.getCell("position")
						.getValue());
			if (row.getCell("outPosition").getValue() != null)
				info.setOutPosition((OutPositionInfo) row
						.getCell("outPosition").getValue());
			if (row.getCell("outPosiType").getValue() != null)
				info.setOutPosiType((OutPosiTypeInfo) row
						.getCell("outPosiType").getValue());
			if (row.getCell("adminOrg").getValue() != null)
				info.setAdminOrg((AdminOrgUnitInfo) row.getCell("adminOrg")
						.getValue());
			if (row.getCell("specialtyId").getValue() != null)
				info.setSpecial((SpecialityInfo) row.getCell("specialtyId")
						.getValue());
			if (row.getCell("planNumber").getValue() != null
					&& !row.getCell("planNumber").getValue().equals(""))
				info.setPlanNumber(Integer.parseInt(row.getCell("planNumber")
						.getValue().toString()));
			if (row.getCell("factNumber").getValue() != null
					&& !row.getCell("factNumber").getValue().equals(""))
				info.setFactNumber(Integer.parseInt(row.getCell("factNumber")
						.getValue().toString()));
			if (row.getCell("needNumber").getValue() != null
					&& !row.getCell("needNumber").getValue().equals(""))
				info.setNeedNumber(Integer.parseInt(row.getCell("needNumber")
						.getValue().toString()));
			if (row.getCell("adjustNumber").getValue() != null
					&& !row.getCell("adjustNumber").getValue().equals(""))
				info.setAdjustNumber(row.getCell("adjustNumber").getValue()
						.toString());
			if (row.getCell("gender").getValue() != null
					&& !row.getCell("gender").getValue().equals(""))
				info.setGender((GenderEnum) row.getCell("gender").getValue());
			if (row.getCell("age").getValue() != null
					&& !row.getCell("age").getValue().equals(""))
				info.setAge(row.getCell("age").getValue().toString());
			if (row.getCell("xueli").getValue() != null)
				info.setXueli((DiplomaInfo) row.getCell("xueli").getValue());
			if (row.getCell("specialty").getValue() != null
					&& !row.getCell("specialty").getValue().equals(""))
				info.setSpecialty(row.getCell("specialty").getValue()
						.toString());
			if (row.getCell("exp").getValue() != null
					&& !row.getCell("exp").getValue().equals(""))
				info.setExp(row.getCell("exp").getValue().toString());
			if (row.getCell("duty").getValue() != null
					&& !row.getCell("duty").getValue().equals(""))
				info.setDuty(row.getCell("duty").getValue().toString());
			if (row.getCell("salaryRange").getValue() != null
					&& !row.getCell("salaryRange").getValue().equals(""))
				info.setSalaryRange(row.getCell("salaryRange").getValue()
						.toString());
			if (row.getCell("address").getValue() != null
					&& !row.getCell("address").getValue().equals(""))
				info.setAddress(row.getCell("address").getValue().toString());
			if (row.getCell("comeDate").getValue() != null
					&& !row.getCell("comeDate").getValue().equals("")) {
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				try {
					info.setComeDate(sdf.parse(row.getCell("comeDate")
							.getValue().toString()));
				} catch (ParseException e) {
					ExceptionHandler.handle(e);
				}
			}
			if (row.getCell("reason").getValue() != null
					&& !row.getCell("reason").getValue().equals(""))
				info.setReason(row.getCell("reason").getValue().toString());
			if (row.getCell("remark").getValue() != null
					&& !row.getCell("remark").getValue().equals(""))
				info.setRemark(row.getCell("remark").getValue().toString());
			if (row.getCell("sourceBill").getValue() != null
					&& !row.getCell("sourceBill").getValue().equals(""))
				info.setSourceBill(row.getCell("sourceBill").getValue()
						.toString());
			c.add(info);
		}

		return c;
	}

	public static RequireAdjustBillEntryCollection getRequireAdjustBillEntriesByKDTable(
			KDTable kdtable) {
		RequireAdjustBillEntryCollection c = new RequireAdjustBillEntryCollection();
		RequireAdjustBillEntryInfo info = null;
		IRow row = null;
		int i = 0;
		for (int size = kdtable.getRowCount(); i < size; i++) {
			row = kdtable.getRow(i);
			info = new RequireAdjustBillEntryInfo();
			if (row.getCell("id").getValue() != null)
				info.setId(BOSUuid
						.read(row.getCell("id").getValue().toString()));
			if (row.getCell("position").getValue() != null)
				info.setPosition((PositionInfo) row.getCell("position")
						.getValue());
			if (row.getCell("outPosition").getValue() != null)
				info.setOutPosition((OutPositionInfo) row
						.getCell("outPosition").getValue());
			if (row.getCell("outPosiType").getValue() != null)
				info.setOutPosiType((OutPosiTypeInfo) row
						.getCell("outPosiType").getValue());
			if (row.getCell("adminOrg").getValue() != null)
				info.setAdminOrg((AdminOrgUnitInfo) row.getCell("adminOrg")
						.getValue());
			if (row.getCell("needNumber").getValue() != null
					&& !row.getCell("needNumber").getValue().equals(""))
				info.setNeedNumber(Integer.parseInt(row.getCell("needNumber")
						.getValue().toString()));
			if (row.getCell("reason").getValue() != null
					&& !row.getCell("reason").getValue().equals(""))
				info.setReason(row.getCell("reason").getValue().toString());
			if (row.getCell("remark").getValue() != null
					&& !row.getCell("remark").getValue().equals(""))
				info.setRemark(row.getCell("remark").getValue().toString());
			if (row.getCell("adjustNumber").getValue() != null
					&& !row.getCell("adjustNumber").getValue().equals(""))
				info.setAdjustNumber(row.getCell("adjustNumber").getValue()
						.toString());
			if (row.getCell("addNumber").getValue() != null
					&& !row.getCell("addNumber").getValue().equals(""))
				info.setAddNumber(Integer.parseInt(row.getCell("addNumber")
						.getValue().toString()));
			if (row.getCell("reduceNumber").getValue() != null
					&& !row.getCell("reduceNumber").getValue().equals(""))
				info.setReduceNumber(Integer.parseInt(row.getCell(
						"reduceNumber").getValue().toString()));
			if (row.getCell("sourceEntryID").getValue() != null
					&& !row.getCell("sourceEntryID").getValue().equals(""))
				info.setSourceEntryID(row.getCell("sourceEntryID").getValue()
						.toString());
			c.add(info);
		}

		return c;
	}

	public static void setTableCellValueByInfo(IRow row, IObjectValue billInfo)
			throws Exception {
		if (billInfo instanceof RequireApplyBillEntryInfo)
			setRowValueByInfo(row, (RequireApplyBillEntryInfo) billInfo);
		else if (billInfo instanceof RequireAdjustBillEntryInfo)
			setRowValueByInfo(row, (RequireAdjustBillEntryInfo) billInfo);
	}

	public static void setRowValueByInfo(IRow row,
			RequireApplyBillEntryInfo info) throws Exception {
		row.setUserObject(info);
		if (info.getId() != null)
			row.getCell("id").setValue(info.getId());
		if (info.getPosition() != null)
			row.getCell("position").setValue(info.getPosition());
		if (info.getOutPosition() != null)
			row.getCell("outPosition").setValue(info.getOutPosition());
		if (info.getOutPosiType() != null)
			row.getCell("outPosiType").setValue(info.getOutPosiType());
		if (info.getAdminOrg() != null)
			row.getCell("adminOrg").setValue(info.getAdminOrg());
		if (info.getAdjustNumber() != null)
			row.getCell("adjustNumber").setValue(info.getAdjustNumber());
		if (info.getGender() != null)
			row.getCell("gender").setValue(info.getGender());
		if (info.getAge() != null)
			row.getCell("age").setValue(info.getAge());
		if (info.getXueli() != null)
			row.getCell("xueli").setValue(info.getXueli());
		if (info.getSpecialty() != null)
			row.getCell("specialty").setValue(info.getSpecialty());
		if (info.getExp() != null)
			row.getCell("exp").setValue(info.getExp());
		if (info.getDuty() != null)
			row.getCell("duty").setValue(info.getDuty());
		if (info.getSalaryRange() != null)
			row.getCell("salaryRange").setValue(info.getSalaryRange());
		if (info.getAddress() != null)
			row.getCell("address").setValue(info.getAddress());
		if (info.getComeDate() != null)
			row.getCell("comeDate").setValue(info.getComeDate());
		if (info.getReason() != null)
			row.getCell("reason").setValue(info.getReason());
		if (info.getRemark() != null)
			row.getCell("remark").setValue(info.getRemark());
		if (info.getSpecial() != null)
			row.getCell("specialtyId").setValue(info.getSpecial());
		if (info.getSourceBill() != null)
			row.getCell("sourceBill").setValue(info.getSourceBill());
		if (info.getJob() != null)
			row.getCell("job").setValue(info.getJob());
		row.getCell("planNumber").setValue(new Integer(info.getPlanNumber()));
		row.getCell("factNumber").setValue(new Integer(info.getFactNumber()));
		row.getCell("needNumber").setValue(new Integer(info.getNeedNumber()));
	}

	public static void setRowValueByInfo(IRow row,
			RequireAdjustBillEntryInfo info) throws Exception {
		row.setUserObject(info);
		if (info.getId() != null)
			row.getCell("id").setValue(info.getId());
		if (info.getPosition() != null)
			row.getCell("position").setValue(info.getPosition());
		if (info.getOutPosition() != null)
			row.getCell("outPosition").setValue(info.getOutPosition());
		if (info.getOutPosiType() != null)
			row.getCell("outPosiType").setValue(info.getOutPosiType());
		if (info.getAdminOrg() != null)
			row.getCell("adminOrg").setValue(info.getAdminOrg());
		if (info.getAdjustNumber() != null)
			row.getCell("adjustNumber").setValue(info.getAdjustNumber());
		if (info.getReason() != null)
			row.getCell("reason").setValue(info.getReason());
		if (info.getRemark() != null)
			row.getCell("remark").setValue(info.getRemark());
		if (info.getSourceEntryID() != null)
			row.getCell("sourceEntryID").setValue(info.getSourceEntryID());
		row.getCell("needNumber").setValue(new Integer(info.getNeedNumber()));
		row.getCell("addNumber").setValue(new Integer(info.getAddNumber()));
		row.getCell("reduceNumber").setValue(
				new Integer(info.getReduceNumber()));
	}

	public static String getSelfBillId(BOSObjectType billBosType,
			String personId, boolean isInProcess) throws BOSException,
			EASBizException {
		return HRRecBaseFacadeFactory.getRemoteInstance().getSelfBillId(
				billBosType, personId, isInProcess);
	}

	public static void showErrorMessage(String RES, String message,
			CoreUI uiObject) {
		MsgBox.showError(uiObject, EASResource.getString(RES, message));
		uiObject.setCursorOfDefault();
		SysUtil.abort();
	}
}


/*
	DECOMPILATION REPORT

	Decompiled from: F:\bos\workspace\eascanon\lib\client\eas\hr_rec-client.jar
	Total time: 63 ms
	Jad reported messages/errors:
Method <init>
Method checkIsAudited
Method getEntriesByKDTable
Method getRequireApplyBillEntriesByKDTable
Method getRequireAdjustBillEntriesByKDTable
Method setTableCellValueByInfo
Method setRowValueByInfo
Method setRowValueByInfo
Method getSelfBillId
Method showErrorMessage
#classes: 1, #methods: 10, #fields: 0, elapsed time: 0.016s
	Exit status: 0
	Caught exceptions:
*/